Created a Com component but how to use it from DXL

Hi all,

I have created my own Com component which I want to use in DXL e.g. as

oleCreateAutoObject("TFSCOMLibrary.TFSComClass")

I do not now much of Com - my component is just a wrapper - but my code looks like below. Before I can use the com component I assume I have to do some configration.

1. Do I have to register the Com component and how?

2. Do I have put the Com dll in some specific directory?

 

using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
using System.Data.SqlClient;
 
using TFSLibrary;
 
namespace TFSCOMLibrary
{
    [Guid("081caf54-89d8-4ae9-b224-c6fd5ca329b7")]
    [ComVisible(true)]
    public interface ITfscomInterface
    {
        [DispId(1)]
        bool ReadTask(int doorsProxyId, out string state);
 
        [DispId(2)]
        bool FetchTask(int doorsProxyId);
    }
 
    [Guid("00f5a31a-67cd-4c3c-a211-fded09eb8276"),
    InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface ITfsComEvents
    {
    }
 
    [Guid("28dc8a68-bc10-4f50-b226-89a0bf650233"),
    ClassInterface(ClassInterfaceType.None),
    ComSourceInterfaces(typeof(ITfsComEvents))]
    [ComVisible(true)]
    public class TfsComClass : ITfscomInterface
    {
        private TfsLibrary _tfsLibrary;
        public TfsComClass()
        {
            _tfsLibrary = new TfsLibrary();
        }
 
        public bool ReadTask(int doorsProxyId, out string state)
        {
            return _tfsLibrary.ReadTask(doorsProxyId, out state);
        }
 
        public bool FetchTask(int doorsProxyId)
        {
            return _tfsLibrary.FetchTask(doorsProxyId);
        }
    }
}

 


jukkaaakula - Thu May 21 03:26:39 EDT 2015

Re: Created a Com component but how to use it from DXL
Mathias Mamsch - Mon May 25 05:09:47 EDT 2015

This is not a DXL question - you need to register your COM object to be able to use it from DXL. For this you use the regsvr tool:

https://msdn.microsoft.com/en-us/library/ms859484.aspx

Search MSDN for more informations on that one. Regards, Mathias

Re: Created a Com component but how to use it from DXL
jukkaaakula - Mon May 25 09:08:53 EDT 2015

Mathias Mamsch - Mon May 25 05:09:47 EDT 2015

This is not a DXL question - you need to register your COM object to be able to use it from DXL. For this you use the regsvr tool:

https://msdn.microsoft.com/en-us/library/ms859484.aspx

Search MSDN for more informations on that one. Regards, Mathias

Thank you! Your proposal moved me much forward:

Now I tried regsvr32 as proposed in the link you gave - but it gave an error. Then I followed following guideleine:

"... if this isn't a hard-named/certificate created DLL (i.e. for pushing into the global assembly cache):

1) Use regasm with the /tlb option, example: regasm mydll.dll /tlb:mydll.tlb
2) Push the dll into the working directory of the executable.  If in design mode, this will be where the VB6.EXE is located (default is like C:\Program Files\Microsoft Visual Studio\VB98).  For compiled executables, just drop it in the same directory as the executable or where you launch if you launch with a shortcut."

https://social.msdn.microsoft.com/Forums/en-US/d5c5ff4a-63d3-49ea-a20d-50ef45924b2e/dllregisterserver-entry-point-was-not-found?forum=vbinterop

Thus I used

regasm TFSCOMLibrary.tlb.dll /tlb=TFSCOMLibrary.tlb 

where TFSCOMLibrary.dll is my dll.

Then I moved the dll and tlb in the same directory as where the dxl is. However oleCreateAutoObject still returns null

batchTaskObject=oleCreateAutoObject("TFSCOMLibrary.TfsComClass")

 

Re: Created a Com component but how to use it from DXL
jukkaaakula - Tue May 26 02:45:07 EDT 2015

jukkaaakula - Mon May 25 09:08:53 EDT 2015

Thank you! Your proposal moved me much forward:

Now I tried regsvr32 as proposed in the link you gave - but it gave an error. Then I followed following guideleine:

"... if this isn't a hard-named/certificate created DLL (i.e. for pushing into the global assembly cache):

1) Use regasm with the /tlb option, example: regasm mydll.dll /tlb:mydll.tlb
2) Push the dll into the working directory of the executable.  If in design mode, this will be where the VB6.EXE is located (default is like C:\Program Files\Microsoft Visual Studio\VB98).  For compiled executables, just drop it in the same directory as the executable or where you launch if you launch with a shortcut."

https://social.msdn.microsoft.com/Forums/en-US/d5c5ff4a-63d3-49ea-a20d-50ef45924b2e/dllregisterserver-entry-point-was-not-found?forum=vbinterop

Thus I used

regasm TFSCOMLibrary.tlb.dll /tlb=TFSCOMLibrary.tlb 

where TFSCOMLibrary.dll is my dll.

Then I moved the dll and tlb in the same directory as where the dxl is. However oleCreateAutoObject still returns null

batchTaskObject=oleCreateAutoObject("TFSCOMLibrary.TfsComClass")

 

Problem probably solved!

regasm needs to have "/codebase"